var express = require("express");
var router = express.Router();

const findRoomsModel = require("../models/findRooms_module");

// 查找找室友页面数据 -- (上拉加载下拉刷新)
router.post("/list", function (req, res, next) {
  const { size, page } = req.body;

  findRoomsModel.count({}, (err, count) => {
    if (err) throw err;
    console.log(size);
    console.log(page);
    console.log(count);

    findRoomsModel
      .find({})
      .skip(+size * (+page - 1))
      .limit(+size)
      .exec((err, doc) => {
        if (err) throw err;
        res.json({
          status: 0,
          list: doc,
          count,
        });
      });
  });
});

module.exports = router;
